//
//  Utils.h
//  YHApp
//
//  Created by jqc on 16/6/13.
//  Copyright © 2016年 silysolong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Photos/Photos.h>

@interface Utils : NSObject
#pragma 正则匹配用户密码6-18位数字和字母组合
+ (BOOL)checkPassword:(NSString *) password;

+ (BOOL) isEmpty:(NSString *) str;

//是否是今天
+ (BOOL)isToday:(NSDate *)date;

//验证手机号码
+ (BOOL)checkCellPhoneNum:(NSString *)num;

//检查邮箱格式
+ (BOOL)checkEmail:(NSString *)text;

//检查身份证格式
+ (BOOL)checkIDNumber:(NSString *)text;

//+ (BOOL)validateMobile:(NSString *)mobileNum;
+ (BOOL)isMobileNumber:(NSString *)mobileNum;

//返回距离当前时间的间隔
+ (NSString *)timeStringWithDate:(NSDate *)date isCustomFriendList:(BOOL)isList;

//返回当前时间的字符串信息
+ (NSString *)getStringWithNowTime;

//返回time时间的date类型
+ (NSDate *)getDateWithString:(NSString*)time;

//返回当前时间 去除8小时误差
+ (NSDate *)getLocalDateNow;

//返回当天零点时间
+ (NSDate *)zeroDateOfToday;

//裁剪图片
+ (UIImage *)fixOrientation:(UIImage *)aImage;

//生成图片
+ (UIImage*) GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height;

//将图片变灰
+ (UIImage*)getGrayImage:(UIImage*)sourceImage;

//图片压缩到指定大小 比下面的好用
+ (UIImage *)imageCompressForSize:(UIImage *)sourceImage targetSize:(CGSize)defineSize;

//图片压缩到指定大小
+ (UIImage *)imageByScalingAndCroppingForSize:(CGSize)targetSize fromImage:(UIImage *)oldImage;

//获取视频某一帧的图片
+ (UIImage*)thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time;

/**
 将数组转换成json字符串

 @param aArray 需要转换的数组
 @return json字符串
 */
+ (NSString *)jsonFromArray:(NSArray *)aArray;

/**
 将json字符串转成数组

 @param jsonStr 需要转换的字符串
 @return 数组
 */
+ (NSArray *)josnToArray:(NSString *)jsonStr;

/**
 将字典转换成json字符串

 @param dict 需要转换的字典
 @return json字符串
 */
+ (NSString *)dictionaryToJson:(NSDictionary *)dict;

/**
 解析json字符串转换成dict
 
 @param jsonString 需要转换json字符串
 @return NSDictionary字典
 */
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;

+ (NSDictionary *)dateWithDateString:(NSString *)string;

/**
 直接打开系统相机

 @param delegate 需要调用的类<需要实现协议UINavigationControllerDelegate，UIImagePickerControllerDelegate>
 */
+(void)takePhoto:(id<UINavigationControllerDelegate, UIImagePickerControllerDelegate>)delegate;

/** 获取当前屏幕显示的viewcontroller */
+ (UIViewController *)getCurrentVC;
+ (UIViewController *)getCurrentVCWithSubView:(UIView *)subView;

/**
 删除指定路径的文件

 @param path 文件路径
 */
+(void)removeFileWithPath:(NSString *)path;

/**
 按照指定的文件名称生成文件

 @param data 文件的二进制数据
 @param name 文件名称
 @return 文件保存路径
 */
+(NSString *)saveFileWithData:(NSData *)data fileName:(NSString *)name;

/**
 将输入字符串与今天作比较，时间是今天则返回HH:mm,不是今天则返回yyyy-MM-dd
 
 @param date 需要比较的日期
 @return 转换好的字符串传
 */
+ (NSString *)compareTimeIsTodayWithDate:(NSDate *)date;

+(void)urlFromPHAsset:(PHAsset *)phasset completion:(void (^)(NSData * videoData))completion;

+ (NSString *)getTimeFromTimestamp:(NSInteger)time;

@end
